package com.hyt.it.ogt.ks.controller;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.hyt.common.apiInfor.ApiResponse;
import com.hyt.it.ogt.ks.enums.BizStatusCode;
import com.hyt.it.ogt.ks.model.entity.CollectLog;
import com.hyt.it.ogt.ks.model.vo.monitor.response.WxLoginVO;
import com.hyt.it.ogt.ks.service.ICollectLogService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiOperationSort;
import io.swagger.annotations.ApiSort;
import lombok.extern.slf4j.Slf4j;

/**
 * 微信小程序
 *
 * @author 刘恒活
 * @since 2021/7/21 10:31
 */
@Api(tags = "14.日志接口", value = "日志接口")
@ApiSort(14)
@Slf4j
@RestController
@RequestMapping("/ks/collect/log/")
public class CollectLogController {
    @Resource
    private ICollectLogService iCollectLogService;

    @ApiOperation(value = "14.1 记录日志")
    @ApiOperationSort(1)
    @PostMapping("add")
    public ApiResponse add(@RequestBody CollectLog wxLog) {
        try {
            iCollectLogService.save(wxLog);
            return ApiResponse.<WxLoginVO>builder().code(BizStatusCode.KS_SUCCESS_OK.getCode()).build();
        } catch (Exception e) {
            log.error("记录微信小程序日志异常：{}", e);
            return ApiResponse.<WxLoginVO>builder().code(BizStatusCode.WX_ADD_LOG_ERROR.getCode()).build();
        }
    }

}
